package ${packageUri}.controller;

import com.zhcs.assistant.common.constants.BusinessConstants;
import com.zhcs.assistant.pojo.request.${className}Insert;
import com.zhcs.assistant.pojo.request.${className}Update;
import com.zhcs.assistant.pojo.request.${className}Query;
import com.zhcs.assistant.pojo.response.PageResult;
import com.zhcs.assistant.pojo.response.Result;
import com.zhcs.assistant.pojo.response.${className}VO;
import ${packageUri}.service.${className}Service;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName ${className}Controller
 * @Description ${className}Controller
 * @Author duqc
 * @Date ${time}
 **/
@RestController
@RequiredArgsConstructor
@RequestMapping("")
public class ${className}Controller {

    private final ${className}Service ${lowClassName}Service;

    /**
    * 新增
    *
    * @param ${lowClassName}Insert 数据
    * @return Result
    */
    @Operation(summary = "-新增")
    @PostMapping("/insert")
    public Result<Boolean> insert(@Validated @RequestBody ${className}Insert ${lowClassName}Insert) {
        this.${lowClassName}Service.insert(${lowClassName}Insert, BusinessConstants.WEB_TYPE);
        return Result.success(Boolean.TRUE);
    }

    /**
    * 修改
    *
    * @param ${lowClassName}Update 数据
    * @return Result
    */
    @Operation(summary = "-修改")
    @PostMapping("/update")
    public Result<Boolean> update(@Validated @RequestBody ${className}Update ${lowClassName}Update) {
        this.${lowClassName}Service.update(${lowClassName}Update);
        return Result.success(Boolean.TRUE);
    }

    /**
    * 列表查询
    *
    * @param pageQuery 查询条件
    * @return PageResult
    */
    @Operation(summary = "-列表查询")
    @PostMapping("/queryPage")
    public PageResult<${className}VO> queryPage(@Validated @RequestBody ${className}Query pageQuery) {
        return PageResult.success(this.${lowClassName}Service.queryPage(pageQuery));
    }

    /**
    * 查询详情
    *
    * @param id id
    * @return ${className}VO
    */
    @Operation(summary = "-查询详情")
    @GetMapping("/info")
    public Result<${className}VO> info(@Schema(description = "ID") Long id) {
        return PageResult.success(this.${lowClassName}Service.info(id));
    }

    /**
    * 删除
    *
    * @param id ID
    * @return Result
    */
    @Operation(summary = "-删除")
    @GetMapping("/delete")
    public Result<Boolean> delete(@Schema(description = "ID") Long id) {
        this.${lowClassName}Service.delete(id);
        return Result.success(Boolean.TRUE);
    }

}
